package name.huzhenbo.java.objects;

class ValidCloneableSub extends ValidCloneable{
    private String other;

    public ValidCloneableSub(int i, String string, PhoneNumber phoneNumber, String other) {
        super(i, string, phoneNumber);
        this.other = other;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        // Should call super.clone()
        // To maintain x.clone().class == x.class, we should call super.clone() to create the object, otherwise
        // something unexpected will happen. e.g. super class return cloned object by constructor, and subclass's clone
        // will return a wrong class. (If super call constructor to create validCloneable, then it's impossible to cast
        // to sub class)
        return super.clone();
    }

    public String getOther() {
        return other;
    }
}
